package com.mallcai.bigdata.ladon.dpl.mapper.report;

import com.mallcai.bigdata.ladon.dpl.entity.report.ReportColumn;
import com.mallcai.bigdata.ladon.dpl.mapper.report.provider.ReportColumnSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface ReportColumnMapper {
    @InsertProvider(type = ReportColumnSqlProvider.class, method = "insert")
    int insert(ReportColumn reportColumn);

    @UpdateProvider(type = ReportColumnSqlProvider.class, method = "update")
    int update(ReportColumn reportColumn);

    @DeleteProvider(type = ReportColumnSqlProvider.class, method = "delete")
    int delete(ReportColumn reportColumn);

    @Select({
            "SELECT * FROM " + ReportColumnSqlProvider.TB_REPORT_COLUMN + " WHERE archive = 0 AND report_id = #{reportId}"
    })
    List<ReportColumn> getByReportId(@Param("reportId") Long reportId);

    @Delete({
            "DELETE FROM " + ReportColumnSqlProvider.TB_REPORT_COLUMN + " WHERE report_id = #{reportId}"
    })
    int delByReportId(@Param("reportId") Long reportId);
}
